define(['jquery'], function(require, exports, module) {
    function setLeftMenu() {
        var position = $('.position');
        var top = position.offset().top;
        var width = position.width();
        var css = {position: "fixed", top: 1, width: width + 'px'};
        $(window).scroll(function() {
            set();
        });
        set();
        function set() {
            var scrolls = $(window).scrollTop();
            if (scrolls > top) {
                position.css(css);
            } else {
                position.css({position: "initial"});
            }
        }
    }

    function initArticleImg() {
        $('.list-img img').each(function() {
            var obj = $(this);
            var src = obj.attr('data-src');
            if (!src) {
                return;
            }
            src = src.replace(/_800/, '_200');
            var img = new Image();
            img.onload = function() {
                obj.attr('src', src);
                var w = obj.width();
                var h = obj.height();
                if (w >= h) {
                    obj.css({'height': '100%'});
                } else {
                    obj.css({'width': '100%'});
                }
            }
            img.src = src;
        });
    }

    exports.init = function() {
        setLeftMenu();
        initArticleImg();
    }
    exports.setLeftMenu = setLeftMenu;
});